﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DataAccess.Transaction;
using SIPO.Library.DataAccess.Administration.Catalog;
using System.Configuration;

namespace SIPO.Web.Forms.Transaction
{
    public partial class recRegistrationDebtorAfterform : BasePage
    {
        private int id = -1;
        protected override void OnLoad(EventArgs e)
        {
            if (Request.Params["id"] != null)
            {
                id = Convert.ToInt32(Request.Params["id"]);
            }

            if (!Page.IsPostBack)
            {
                recSectorRepo recSectorDal = new recSectorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                recSubSectorRepo recSubSectorDal = new recSubSectorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                recSubSubSectorRepo recSubSubSectorDal = new recSubSubSectorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                recRegionRepo recRegionDal = new recRegionRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                recCityRepo recCityDal = new recCityRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                recEmisionTypeRepo recEmisionTypeDal = new recEmisionTypeRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);

                //populate dropdownlist sector
                List<recSector> sectors = recSectorDal.GetList();
                ddlSector.Items.Clear();
                sectors.ForEach(delegate(recSector sector)
                {
                    ddlSector.Items.Add(new ListItem(sector.SectorCode + "-" + sector.SectorName, sector.SectorID.ToString()));
                });
                ddlSector.Items.Insert(0, new ListItem("-- pilih sector --", string.Empty));

                //populate dropdownlist Sub sector
                ddlSubSector.Items.Insert(0, new ListItem("-- pilih sub sector --", string.Empty));

                //populate dropdownlist Sub sector
                ddlSubSubSector.Items.Insert(0, new ListItem("-- pilih sub sub sector --", string.Empty));

                //populate dropdownlist Region
                List<recRegion> regions = recRegionDal.GetList();
                ddlWilayah.Items.Clear();
                regions.ForEach(delegate(recRegion region)
                {
                    ddlWilayah.Items.Add(new ListItem(region.RegionCode + " - " + region.RegionName, region.RegionID.ToString()));
                });
                ddlWilayah.Items.Insert(0, new ListItem("-- pilih propinsi  --", string.Empty));

                //populate dropdownlist kota
                ddlKota.Items.Insert(0, new ListItem("-- pilih kota  --", string.Empty));
            }

        }
    }
}